<template>
	<view class="courses_student">
		<view class="course_Item_item">
			<image :src="query.image" mode="aspectFill" class="uimg"></image>
			<view class="right_comlumn">
				<view class="title">
					{{query.title}}
				</view>
				<view class="content">
					{{query.intro}}
				</view>
				<view class="row-box">
					<view v-for="(Skuitem,Skuindex) in query.label_list" :key="Skuindex" class="Skuitem">
						{{Skuitem.title}}
					</view>
				</view>
				<view class="bottom">
					<view class="left">
						<text class="red size1">￥</text>
						<text class="red size2">{{query.price}}</text>
						<text class="red size3">/节</text>
						<text class="td size3 gray">￥{{query.cost}}/节</text>
					</view>
				</view>
			</view>
		</view>
		<view class="tab">
			<view v-for="(item,index) in tabList" :key="index" class="tabIndex" @click="changeIndex(index)">
				<view :class="activeIndex == index ?'tabsize1':'tabsize2'">
					{{item}}
				</view>
				<view class="active">
					<view class="empty" v-if="activeIndex == index">
		
					</view>
				</view>
			</view>
		</view>
		<scroll-view scroll-y="true" class="scroll-Y">
			<view class="comlumn_box" v-if="list.length">
				<view v-for="(item,index) in list" :key="index" class="Item" @click="routecourse(item, index)">
					<view class="img">
						<image :src="$IMG_URL('/static/user/notlog.png')" mode="" class="avater"></image>
						<image
							:src="item.sex ?$IMG_URL('/static/mannager/girl.png'):$IMG_URL('/static/mannager/boy.png')"
							mode="" class="sex"></image>
					</view>
					<view class="right">
						<view class="title">
							{{item.title}}
						</view>
						<view class="bottom">
							<view class="size">
								{{item.des_str}}
							</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
				</view>
				<u-loadmore :status="status" />
			</view>
			<empty v-else :content="!activeIndex?'进行中课程':'已完成课程'"></empty>
		</scroll-view>
	</view>
</template>

<script>
	import{
		coachStudentCourse
	} from '@/api/coach.js'
	import empty from './components/empty.vue'
	export default {
		components: {
			empty
		},
		data(){
			return{
				initer:{
					course:'',
					form:'unfinished',
					page:1
				},
				query:{},
				// 导航
				tabList: [
					'进行中(0)',
					'已完成(0)',
				],
				activeIndex: 0,
				list:[],
				status: 'loadmore', //当前状态
			}
		},
		onLoad(e) {
			this.initer.course = e.course
			this.getCoach()
			this.getCoachStudentCourse()
		},
		methods:{
			routecourse(item, index){
				uni.navigateTo({
					url:'record?my_course_id=' + item.my_course_id
				})
			},
			changeIndex(index) {
				if(this.activeIndex != index){
					if(!index){
						this.initer.form = 'unfinished'
					}else{
						this.initer.form = 'finish'
					}
					this.activeIndex = index
					this.list = []
					this.initer.page = 1
					this.getCoachStudentCourse()
				}
			},
			getCoach(){
				coachStudentCourse(this.initer).then(({data:res})=>{
					console.log('res', res);
					if(res.code == 1){
						this.query = res.data.course_info
						this.tabList[0] = '进行中(' + res.data.unfinished_num + ')'
						this.tabList[1] = '已完成(' + res.data.finish_num + ')'
					}
				})
			},
			getCoachStudentCourse(){
				coachStudentCourse(this.initer).then(({data:res})=>{
					console.log('res', res);
					if(res.code == 1){
						const list = []
						this.status = 'loading'
						if (this.query.page > res.data.all_page) {
							console.log('nomore');
							this.status = 'nomore'
							return false
						} else {
							console.log('more');
							this.status = 'more'
							this.list = this.list.concat(res.data.list)
						}
						
						console.log('list', this.list);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #e9e9e9;
	}
	.courses_student{
		display: flex;
		flex-direction: column;
		align-items: center;
		.course_Item_item{
			display: flex;
			flex-direction: row;
			align-items: center;
			width: 750rpx;
			height: 278rpx;
			background: #ffffff;
			border-radius: 16rpx;
			padding: 20rpx;
			.uimg{
				width: 230rpx;
				height: 230rpx;
				background: rgba(0,0,0,0.00);
				border-radius: 16rpx;
				margin-right: 20rpx;
			}
			
			.right_comlumn{
				display: flex;
				flex-direction: column;
				flex: 1;
				height: 100%;
				.title{
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 700;
					text-align: left;
					color: #333333;
					margin-bottom: 4rpx;
				}
				.content{
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #666666;
					margin-bottom: 12rpx;
				}
				.row-box{
					display: flex;
					flex-direction: row;
					align-items: center;
					flex-wrap: wrap;
					flex: 1;
					.Skuitem{
						padding: 0 6rpx;
						height: 28rpx;
						background: #ededed;
						border-radius: 4rpx;
						margin-right: 6rpx;
						font-size: 20rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #666666;
						display: flex;
						align-items: center;
						justify-content: center;
					}
				}
			}
		}
					
		.bottom{
			display: flex;
			flex-direction: row;
			align-items: center;
			
			.left{
				display: flex;
				flex-direction: row;
				align-items: baseline;
				flex: 1;
				.red{
					color: #F37364;
				}
				.gray{
					color: #999999;
				}
				.fw1{
					font-weight: 700;
				}
				.fw2{
					font-weight: 500;
				}
				.size1{
					font-size: 24rpx
				}
				.size2{
					font-size: 32rpx
				}
				.size3{
					font-size: 20rpx
				}
				.td{
					font-weight: 400;
					margin-left: 6rpx;
					text-decoration:  line-through;
				}
			}
			.btn{
				transform: rotateZ(360deg);
				width: 152rpx;
				height: 64rpx;
				background: #73F0EA;
				border: 1rpx solid #73F0EA;
				border-radius: 16rpx;
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-Bold;
				font-weight: 700;
				text-align: center;
				color: #ffffff;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
		.tab {
			width: 100%;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-around;
			background: #ffffff;
			padding-top: 40rpx;
		
			.tabIndex {
				display: flex;
				flex-direction: column;
				align-items: center;
		
				.tabsize1 {
					height: 44rpx;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Heavy;
					font-weight: 800;
					text-align: center;
					color: #73F0EA;
					letter-spacing: 0.7rpx;
		
				}
		
				.tabsize2 {
					height: 44rpx;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Regular;
					font-weight: 400;
					text-align: center;
					color: #666666;
					letter-spacing: 0.7rpx;
		
				}
		
				.active {
					margin-top: 12rpx;
					width: 44rpx;
					height: 8rpx;
		
					.empty {
						width: 100%;
						height: 100%;
						background: #73F0EA;
						border: 2rpx solid rgba(0, 0, 0, 0.00);
						border-radius: 2rpx;
					}
				}
			}
		}
	}
	.scroll-Y {
		width: 100%;
		height: 71vh;
		.comlumn_box {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 24rpx;
	
			.Item {
				width: 702rpx;
				height: 128rpx;
				background: #ffffff;
				border-radius: 16rpx;
				padding: 0 24rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-bottom: 20rpx;
	
				.img {
					width: 80rpx;
					height: 80rpx;
					background: #f6f6f6;
					border-radius: 50%;
					position: relative;
					margin-right: 20rpx;
	
					.avater {
						width: 100%;
						height: 100%;
					}
	
					.sex {
						position: absolute;
						right: 0;
						bottom: 0;
						width: 26rpx;
						height: 26rpx;
					}
				}
	
				.right {
					display: flex;
					flex-direction: column;
					flex: 1;
	
					.title {
						font-size: 32rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						font-weight: 700;
						text-align: left;
						color: #333333;
					}
					.bottom{
						display: flex;
						flex-direction: row;
						align-items: center;
						.size{
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Regular;
							font-weight: 400;
							text-align: left;
							color: #000000;
						}
						.size1{
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Regular;
							font-weight: 400;
							text-align: left;
							color: #999999;
						}
						.gang{
							width: 0rpx;
							height: 24rpx;
							border: 1rpx solid #000000;
							margin: 0 10rpx;
						}
					}
				}
			}
		}
	}
</style>